<%@ page language="java" import="java.util.*,com.ruohi.util.common.*,com.ruohi.util.dbutil.*,java.sql.*" pageEncoding="UTF-8"%>
<%@page import="com.ruohi.manage.ApplicationListener"%>
<%@page import="com.ruohi.manage.PoolManager"%>
<%@page import="com.ruohi.manage.DBType"%><%
	String event = CommonString.getFormatPara(request.getParameter("eventAfter"));
	String [] eventArr = event.split(",");
	List<String> eventList =Arrays.asList(eventArr);
	DBHelper dbHelper = DBHelper.getInstance();
	Connection connection = null;
	Map model = null;
	try{
		connection = dbHelper.getConnection();
		connection.setAutoCommit(false);
		
		//枚举更新Application
		if(eventList.contains("updateApplicationEnum")){
			CommonApplication.getEnumMap(application);
		}
		//栏目更新Application
		if(eventList.contains("updateApplicationChannel")){
			CommonApplication.getChannelMap(application);
		}
		//商品网更新类别
		if(eventList.contains("updAppCategoryGift")){
			ApplicationListener.getCategoryMapGift(application);
		}
		//商品网品牌更新
		if(eventList.contains("updAppBrandGift")){ 
			ApplicationListener.getBrandMapGift(application);
		}
		//商品网供应商更新appication
		if(eventList.contains("updAppSupplierGift")){ 
			ApplicationListener.getSupplierMapGift(application);
		}
		//商品网过滤关键词更新application
		if(eventList.contains("updAppFilterKeywords")){
			
		}
		
		// 栏目静态页生成
		if(eventList.contains("createChannel")){
			String cUrl = CommonString.getFormatPara(request.getParameter("zd_template_file_name"));
			String id = CommonString.getFormatPara(request.getParameter("updateId")).equals("")?CommonString.getFormatPara(request.getParameter("keyId")):CommonString.getFormatPara(request.getParameter("updateId")) ;
			if(!cUrl.equals("")){
				Map m = new HashMap() ;
				m.put("id",id) ;
				Common.doPostHttpAsync(cUrl,m) ;
			}
		}
		
		//存元素和频道的关系
		if(eventList.contains("saveChannelSubblock")){
			//信息表
			String id = CommonString.getFormatPara(request.getParameter("keyId"));
			String channel_uuid = CommonString.getFormatPara(request.getParameter("channel_uuid"));
			String [] cuuidArr = channel_uuid.split(",");
			Map subblock = dbHelper.getMap(" select * from "+"service_common_channel_subblock where id = ? ",new Object [] {id},connection);
			String uuid = (String)subblock.get("uuid");
			dbHelper.execute(" delete from " + "service_common_acl_channel_subblock where subblock_uuid = ? " , new Object [] {uuid},connection);
			for(int i=0;i<cuuidArr.length;i++){
				dbHelper.execute(" insert into "+"service_common_acl_channel_subblock ( channel_uuid , subblock_uuid ) values ( ? , ? )", new Object [] {cuuidArr[i],uuid},connection);
			}
		}
		//删除元素和频道的关系
		if(eventList.contains("deleteChannelSubblock")){
			String id = CommonString.getFormatPara(request.getParameter("del_id"));
			dbHelper.execute(" delete from "+"service_common_acl_channel_subblock where subblock_uuid in ("+id+") " , connection);
		}
		// 职场攻略生成静态页
		if(eventList.contains("CmjobCreateNews")){
			String id = CommonString.getFormatPara(request.getParameter("keyId"));
			String updateId = CommonString.getFormatPara(request.getParameter("updateId")) ;
			if("".equals(id) &&!"".equals(updateId)){
				id = updateId ;
			}
			Map myMap = new HashMap() ;
			myMap.put("myvalue",id) ;
			myMap.put("zd_catalog_no","60010104") ;
			myMap.put("flag","4") ;
		 	//Common.doPostHttpAsync("http://job.21-sun.com/tools/create/from_manage_create.jsp",myMap) ;
		}
		// 法律法规生成静态页
		if(eventList.contains("CmjoblawCreateNews")){
			String id = CommonString.getFormatPara(request.getParameter("keyId"));
			String updateId = CommonString.getFormatPara(request.getParameter("updateId")) ;
			if("".equals(id) &&!"".equals(updateId)){
				id = updateId ;
			}
			Map myMap = new HashMap() ;
			myMap.put("myvalue",id) ;
			myMap.put("zd_catalog_no","60010103") ;
			myMap.put("flag","4") ;
		 	//Common.doPostHttpAsync("http://job.21-sun.com/tools/create/from_manage_create.jsp",myMap) ;
		}
		// 生成维修一线静态页
		if(eventList.contains("createStaticPage")){ 
			Map myMap = new HashMap() ;
			String updateId = CommonString.getFormatPara(request.getParameter("updateId")) ;
			myMap.put("manage","manage") ;
			myMap.put("mypy","article_other") ; 
			myMap.put("zd_catalog_no","700301") ; // myvalue
			myMap.put("myvalue",CommonString.getFormatPara(request.getParameter("keyId"))) ;
			if("".equals(updateId)){
				//Common.doPostHttpAsync("http://member.21-sun.com/back/tech/opt_save_update.jsp",myMap) ;
			}
		}
		
		//更新提现订单
		if(eventList.contains("updatePayoffOrder")){ 
			String zd_order_status = CommonString.getFormatPara(request.getParameter("zd_order_status")) ;
			String zd_member_order_no = CommonString.getFormatPara(request.getParameter("zd_member_order_no")) ;
			String zd_partner_order_no = CommonString.getFormatPara(request.getParameter("zd_partner_order_no")) ;
			connection = PoolManager.getConnection(DBType.getDBTypeByEnum("106013"));
			connection.setAutoCommit(false);
			if(zd_order_status.equals("100")){
				//会员
				if(!zd_member_order_no.equals("")){
					//order表
					String upMemberOrderStr = "update gift_order set member_payoff_status=100 where order_num in ("+zd_member_order_no+")";
					dbHelper.execute(upMemberOrderStr,connection);
					//order_payoff表
					String upMemberPayoffStr = "update gift_order_payoff set order_status=100 where order_num in ("+zd_member_order_no+")";
					dbHelper.execute(upMemberPayoffStr,connection);
				}
				//合伙人
				if(!zd_partner_order_no.equals("")){
					//order表
					String upPartnerOrderStr = "update gift_order set partner_payoff_status=100 where order_num in ("+zd_partner_order_no+")";
					dbHelper.execute(upPartnerOrderStr,connection);
					//order_payoff表
					String upPartnerPayoffStr = "update gift_order_payoff set order_status=100 where order_num in ("+zd_partner_order_no+")";
					dbHelper.execute(upPartnerPayoffStr,connection);
				}
			}
		}
		
		connection.commit();
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		DBHelper.freeConnection(connection);
	}
	Common.doForward(request,response,"/backend/action/after_own.jsp");
%>